<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

手机号码: <label>
    <input type="number">
</label>
<button>发送验证码</button>


<script>

    var btn = document.querySelector('button');
    var count = 10;


    btn.addEventListener('click', function () {
        this.disabled = true;
        // 这里的 btn 改成 this
        this.innerHTML = `还剩下${count}s`;
        const timer = setInterval(function () {
            // console.log(this)  指向的 window
            if (count > 0) {
                count--
                btn.innerHTML = `还剩下${count}s`;
            } else {
                btn.innerHTML = `发送验证码`;
                btn.disabled = false;
                clearInterval(timer);
                count = 10;     // 这个count需要重新赋值为10
            }
        }, 1000);
    })
</script>
</body>
</html>
